package com.gscitysfy.cus.drain.modules.warning.service.impl;

import com.gscitysfy.cloudfrmwk.assistant.domain.Result;
import com.gscitysfy.cus.drain.modules.warning.entity.DrainMonitorMnAlarm;
import com.gscitysfy.cus.drain.modules.warning.entity.DrainSystemCommandLead;
import com.gscitysfy.cus.drain.modules.warning.mapper.DrainMonitorMnAlarmMapper;
import com.gscitysfy.cus.drain.modules.warning.mapper.DrainSystemCommandLeadMapper;
import com.gscitysfy.cus.drain.modules.warning.service.IDrainMonitorMnAlarmService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 报警表 服务实现类
 * </p>
 *
 * @author Administrator
 * @since 2022-11-08 11:01:16
 */
@Service
public class DrainMonitorMnAlarmServiceImpl extends ServiceImpl<DrainMonitorMnAlarmMapper, DrainMonitorMnAlarm> implements IDrainMonitorMnAlarmService {
    @Autowired
    DrainMonitorMnAlarmMapper drainMonitorMnAlarmMapper;
    @Override
    public Result<Object> getListByQuery(DrainMonitorMnAlarm drainMonitorMnAlarm) {
        if(drainMonitorMnAlarm.getCmKid()!=null){
            List<DrainMonitorMnAlarm> drainMonitorMnAlarmList =drainMonitorMnAlarmMapper.getPageList(drainMonitorMnAlarm);
            if(CollectionUtils.isEmpty(drainMonitorMnAlarmList)){
                return Result.content(null);
            }else{
                return Result.content(drainMonitorMnAlarmList.get(0));
            }
        }else{
            List<DrainMonitorMnAlarm> drainMonitorMnAlarmList =drainMonitorMnAlarmMapper.getPageList(drainMonitorMnAlarm);
            return Result.content(drainMonitorMnAlarmList);

        }

    }
}
